home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form areacode
- Caption = "Area Code Lookup"
- ClientHeight = 2730
- ClientLeft = 1095
- ClientTop = 1695
- ClientWidth = 7905
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 3135
- Icon = AREACODE.FRX:0000
- Left = 1035
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- ScaleHeight = 2730
- ScaleWidth = 7905
- Top = 1350
- Width = 8025
- Begin CommandButton Command1
- Caption = "Look Up Area Code"
- Default = -1 'True
- Height = 375
- Left = 5640
- TabIndex = 6
- Top = 2160
- Width = 2055
- End
- Begin TextBox ac
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 420
- Left = 1800
- TabIndex = 3
- Top = 360
- Width = 735
- End
- Begin Label ltime
- BorderStyle = 1 'Fixed Single
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 1800
- TabIndex = 1
- Top = 1560
- Width = 5895
- End
- Begin Label Label1
- Alignment = 1 'Right Justify
- Caption = "Time:"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 255
- Left = 840
- TabIndex = 0
- Top = 1560
- Width = 735
- End
- Begin Label location
- BorderStyle = 1 'Fixed Single
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 1800
- TabIndex = 5
- Top = 960
- Width = 5895
- End
- Begin Label Label3
- Alignment = 1 'Right Justify
- Caption = "Location:"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 255
- Left = 240
- TabIndex = 4
- Top = 960
- Width = 1335
- End
- Begin Label Label2
- Alignment = 1 'Right Justify
- Caption = "Area Code:"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 255
- Left = 120
- TabIndex = 2
- Top = 360
- Width = 1455
- End
- Dim areacodes(256) As Integer ' All the areacodes
- Dim timezones(256) As Integer ' Timezones from GMT
- Dim areanames(256) As String ' Name of the Area Codes
- Dim numac As Integer ' # of areacodes
- Dim tzhere As Integer ' Local time zone
- Dim tzformat As String ' How we like time/dates formatted
- Sub Command1_Click ()
- ' This routine finds the area code the user has entered, displays the
- ' location and the time at that location. No attempt is made to handle
- ' areacodes which are split across time zones or places that do not
- ' go onto daylight savings time with the rest of the nation...
- Dim i As Integer
- Dim findac As Integer
- findac = Val(ac.text) ' The current areacode as an integer
- ' We mark the areacode the user entered as "selected", so that after
- ' we finish the user can just start typing in a new area code without
- ' having to delete the old one...
- ac.selstart = 0
- ac.sellength = Len(ac.text)
- ' Search ...
- For i = 1 To numac
- If (areacodes(i) = findac) Then
- ' When we find the area code, update the location and local times...
- location.caption = areanames(i)
- ltime.caption = Format$(Now + TimeSerial(tzhere, 0, 0) - TimeSerial(timezones(i), 0, 0), tzformat)
- Exit Sub
- End If
- Next i
- ' We didn't find the area code! Beep, erase all text on the display,
- ' and open a message box to complain!
- Beep
- ac.text = ""
- location.caption = ""
- ltime.caption = ""
- ac.sellength = 0
- MsgBox "Invalid Area Code"
- End Sub
- Sub Form_Load ()
- ' When the form is first loaded, read in the area code database
- loadac
- End Sub
- Sub loadac ()
- ' This routine loads in the area code file, which is
- ' assumed to be called "ac.dat". The file contains
- ' two sections. The first section contains two lines,
- ' the first being the local time zone (offset from GMT),
- ' and the second line holding the time/date format the user
- ' prefers.
- ' The second section contains the list of area codes, one per
- ' line. The format is areacode/GMT offset/name
- Dim s1 As Integer, s2 As Integer ' Location of slashes in text
- Dim f1 As String, f2 As String, f3 As String ' Fields of the text
- mousepointer = 11 ' Say we're busy
- Open "ac.dat" For Input As 1 ' Open the database
- Input #1, tzhere ' Read local time zone
- Line Input #1, tzformat ' Read prefered format
- On Error GoTo done
- ' Read in the table of areacodes
- For numac = 1 To 256
- Line Input #1, l$
- ' First break the line into the three pieces (/ is delimeter)
- s1 = InStr(l$, "/")
- s2 = InStr(s1 + 1, l$, "/")
- f1 = Left$(l$, s1 - 1)
- f2 = Mid$(l$, s1 + 1, s2 - (s1 + 1))
- f3 = Mid$(l$, s2 + 1)
- ' Then, assign our arrays the pieces
- areacodes(numac) = Val(f1)
- timezones(numac) = Val(f2)
- areanames(numac) = f3
- Next numac
- done: Resume done2
- done2:
- ' Decrement numac as it's past the end of the data
- numac = numac - 1
- ' Say we're not busy anymore...
- mousepointer = 0
- End Sub
-